package com.duanfh.Response.impl;

import com.duanfh.Response.Response;
import org.apache.log4j.Logger;

import java.io.OutputStream;

/**
 * @author duanfh
 */
public class MyResponse implements Response {
    private static Logger logger = Logger.getLogger(MyResponse.class);
    private OutputStream outputStream;
    public MyResponse(OutputStream outputStream){
        this.outputStream = outputStream;
    }
    public void write(String str) throws Exception{
        StringBuilder sb = new StringBuilder();
        sb.append("HTTP/1.1 200 OK")
                .append("Content-Type:text/html\n")
                .append("\r\n")
                .append("<html><body><h1>")
                .append(str)
                .append("</html></body></h1>");
        this.outputStream.write(sb.toString().getBytes());
        this.outputStream.flush();
        this.outputStream.close();
    }
}
